package org.jpass.dc.common.util;

import java.util.Date;
import java.util.List;
import java.util.Random;

import org.jpass.dc.business.user.bean.UserGroupVOBean;
import org.jpass.dc.business.user.bean.UserVOBean;
import org.jpass.dc.business.user.logic.UserGroupLogic;
import org.jpass.dc.business.user.logic.UserGroupLogicImpl;
import org.jpass.dc.business.user.logic.UserManageLogic;
import org.jpass.dc.business.user.logic.UserManageLogicImpl;

/**
 * 自动添加用户类
 * **/
public class AutoAddGroup {
	UserGroupVOBean group = new UserGroupVOBean();
	UserManageLogic userManageLogic = new UserManageLogicImpl();
	UserGroupLogic userGroupLogic = new UserGroupLogicImpl();

	public static void main(String[] args) {
		int count = 1; // 新建用户组数量
		try {
			new AutoAddGroup().autoInsertGroup(count);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("已新建" + count + "个用户组！！");
	}

	/** 自动添加用户 **/
	public void autoInsertGroup(int count) throws Exception {
		for (int i = 0; i < count; i++) {
			//group.setGroupName("中级程序员");
			group.setGroupName("高级程序员");
			group.setGroupLevel(2);
			group.setPointBegin(100);
			group.setPointEnd(200);
			userGroupLogic.addGroup(group);
		}
	}

	/**
	 * 产生随机字符串
	 * */
	public String randomString(int length) {
		Random randGen = null;
		char[] numbersAndLetters = null;
		if (length < 4 || length > 18) {
			return null;
		}
		if (randGen == null) {
			randGen = new Random();
			numbersAndLetters = ("abcdefghijklmnopqrstuvwxyz"
					+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
		}
		char[] randBuffer = new char[length];
		for (int i = 0; i < randBuffer.length; i++) {
			randBuffer[i] = numbersAndLetters[randGen.nextInt(51)];
		}
		return new String(randBuffer);
	}

}
